<template>
  <div class="contentBox">
    <searchTop></searchTop>
    <!-- <div>首页</div> -->
    <swperImg :imgList="imgList"></swperImg>
    <div>
      <BrandList :typeID="item.id" :itemData="item" v-for="(item,index) in dailyListC" :key="index" :dailyList="dailyList"></BrandList>
    </div>
    <HotCommodities :HotList="HotList"></HotCommodities>
    <Hotsale :HotList="HotList2"></Hotsale>
    <Guessyoulikeit :likeList="likeList"></Guessyoulikeit>
    <couponeCom ></couponeCom>
  </div>
</template>

<script lang="ts" setup>
import { computed, reactive, ref } from "vue";
import swperImg from "./swperImg.vue"; //轮播图
import searchTop from "../../../components/searchTop.vue"; //搜索组件
import BrandList from "./DailySale.vue"; //此处为天天特卖list
import HotCommodities from "./HotCommodities.vue"; //热卖商品
import Hotsale from "./Hotsale.vue"; //热销商品
import Guessyoulikeit from "./Guessyoulikeit.vue";
import couponeCom from "../couponeCom.vue";
import {
  comgetAd,
  ProductindexProoduct,
  ProductgetGuesslike,
  Indexget_type,
} from "../../../utils/api";
// import { Edit, Delete } from "@element-plus/icons-vue"; // icon 按需引入
//   <el-button type="primary" :icon="Edit" circle></el-button> ---> element plus 使用范例
// defineProps({});

const imgList = ref([]);

comgetAd({ type: 1 }).then((res) => {
  let resp: any = res;
  console.log(resp.code, "lunbotu");
  if (resp.code == 200) {
    imgList.value = resp.data;
  }
});
// -- 热卖商品
const HotList = ref<[]>([]);
const HotList2 = ref<[]>([]);
// 获取 热卖/热销商品
let hot1 = { page: 1, limit: 6, indexType: 0 }; // 热卖参数
let hot2 = { page: 1, limit: 6, indexType: 1 }; // 热销参数
ProductindexProoduct(hot1).then((res) => {
  console.log(res, "热卖商品");
  HotList.value = res.data.data;
});
ProductindexProoduct(hot2).then((res) => {
  console.log(res, "热销商品");
  HotList2.value = res.data.data;
});

// -- 猜你喜欢
const likeList = ref<[]>([]);
let listParams = { page: 1, limit: 12 }; // 猜你喜欢参数
ProductgetGuesslike(listParams).then((res) => {
  likeList.value = res.data.data;
});

// -- 天天特卖
const dailyList = ref([]);
Indexget_type({}).then((res:any) => {
  console.log(res, "获取首页平台大分类--首页");
  if (res.code == 200) {
    console.log(123);
    dailyList.value = res.data
  }
});
const dailyListC = computed(()=>{
  let arr = [...dailyList.value]
  let arr2:any = []
  arr.forEach((item : any,index : number)=>{
    if(!item.is_top){
      arr2.push(item)
    }
  })
  console.log(arr2,'_++++');
  
  return arr2;
})

// -- 品牌特卖

</script>

<style scoped>
.contentBox {
  max-width: 1920px;
  margin: 0 auto;
  background: #f5f5f5;
  padding-bottom: 50px;
}
</style>
